package com.dding.cms.base.web.widget.handler;

import static com.dding.cms.base.web.ActionConstants.WIDGET_SEPERATOR;

import java.util.List;
import java.util.Map;

import org.dding.core.util.StringUtils;

import com.dding.cms.base.web.widget.IWidgetContext;
import com.dding.cms.base.web.widget.IWidgetHandler;

public abstract class AbstractWidgetHandler implements IWidgetHandler {


	@Override
	public Object handleSet(IWidgetContext widgetContext) {
		return null;
	}

	@Override
	public Object handleGet(IWidgetContext widgetContext) {
		return null;
	}

	@Override
	public Object handleUpdateField(IWidgetContext widgetContext) {
		return null;
	}

	@Override
	public Object handleUpdateAssociation(IWidgetContext widgetContext) {
		return null;
	}

	protected String[] getParameterSetValue(String name, String type,
			Map<String, Object> parameter, List<String> ids) {
		String key = name;
		if (StringUtils.isNotEmpty(type))
			key = name + WIDGET_SEPERATOR + type;
		String[] value = (String[])parameter.get(key);
		if (value == null) {
			key = name;
			value = (String[])parameter.get(name);
		}
		if (value != null && ids != null)
			ids.add(key);
		return value;
	}

}
